import zipfile
import os


def unzip(zip_file):
    unzip_dir = str(zip_file).replace(".zip", "_zip")
    with zipfile.ZipFile(zip_file, 'r') as z:
        z.extractall('./' + unzip_dir + '/')
    return unzip_dir


def to_zip(files, zip_file):
    print '------'
    print zip_file
    print files
    print '------'
    with zipfile.ZipFile(zip_file, 'w') as z:
        for element in files:
            z.write(element)


def find_xLog(file_path):
    result = []
    all_files = os.listdir(file_path)
    for ls in all_files:
        if ls.endswith(".xlog"):
            result.append(str(file_path) + '/' + str(ls))

    print result
    return result


if __name__ == '__main__':
    file_list = ['/Users/imac/code/Py/DecodeXLog/static/2021-11-25 15:38:23.206313_zip/main_20211123.xlog.log',
                 '/Users/imac/code/Py/DecodeXLog/static/2021-11-25 15:38:23.206313_zip/main_20211124.xlog.log']
    path = '/Users/imac/code/Py/DecodeXLog/static/2021-11-25 15:38:23.206313_zip/result.zip'
    to_zip(file_list, path)
    print 'c run name ' + os.getcwd()
